﻿using Google.Analytics.Common;
using Google.GData.Client;
using Google.GData.Extensions;

namespace Google.Analytics.Model.Feeds
{
    public class AnalyticsEntry : AbstractEntry
    {
        /// <summary>
        /// Basic method for retrieving Calendar extension elements.
        /// </summary>
        /// <param name="extension">The name of the extension element to look for</param>
        /// <returns>SimpleAttribute, or NULL if the extension was not found</returns>
        public SimpleAttribute GetAnalyticsExtension(string extension)
        {
            return FindExtension(extension, AnalyticsParserNameTable.AnalyticsNamespace) as SimpleAttribute;
        }

        /// <summary>
        /// Base method for retrieving Calendar extension element values.
        /// </summary>
        /// <param name="extension">The name of the Calendar extension element to look for</param>
        /// <returns>value as string, or NULL if the extension was not found</returns>
        public string GetAnalyticsExtensionValue(string extension)
        {
            SimpleAttribute e = GetAnalyticsExtension(extension);
            if (e != null)
            {
                return (string)e.Value;
            }
            return null;
        }
    }
}
